<!DOCTYPE html>
<html>
<head>
	<title></title>
	<!--[if lt IE 9]>
	<meta http-equiv="refresh" content="0;ie.html" />
	<![endif]-->

	<link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
	<link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
	<link href="__STATIC__/layout/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
	<link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
	<link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
	<link href="__STATIC__/layout/css/channel.css?v=4.1.0" rel="stylesheet">
       <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
	<script src="__STATIC__/layout/js/jquery.min.js"></script>
	<!-- Sweet Alert -->
	<link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<!-- Sweet alert -->
	<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
	<!-- layer javascript -->
	<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
    <style type="text/css">
         .checkbox-inline input[type=checkbox],.radio-inline input[type=radio] {
    margin-top: 4px;
}
     #brief{-webkit-user-select:none;-moz-user-select:none;-o-user-select:none;user-select:none;width:70%;height: 60px;}
    </style>
</head>
<body class="white-bg" style="padding: 3px;color: #333">
<div class="page-heade">
	<h2 class="title_color text-center">三级科目管理</h2>
</div>
	<div class="padding-10" >
		<a href="javascript:;" class="btn btn-w-m btn-info" id="new">增加</a>
		<a href="javascript:;" class="btn btn-w-m btn-info" id="tree">查看费用科目树结构</a>
	</div>
	<div class="ibox-content">

		<form role="form" id="form1" class="form-inline" method="get" action="{:url('index')}">
			<div class="row" style="margin-bottom:10px;">
				<div class="col-sm-4 form-group">
					<label for="search1">三级费用科目编号：</label>
					<input type="text" name="sn" value="{if isset($get.sn)}{$get.sn}{/if}" placeholder="请输入科目代码" id="search1" class="form-control">
				</div>
				<div class="col-sm-4 form-group">
					<label for="search2">三级费用科目：</label>
					<input type="text" name="title" value="{if isset($get.title)}{$get.title}{/if}" placeholder="请输入科目名称" id="search2" class="form-control">
				</div>
				<div class="col-sm-4 form-group">
					<label for="search3">对应财务费用科目：</label>
					<input type="text" name="fifeiyongkemu" value="{if isset($get.fifeiyongkemu)}{$get.fifeiyongkemu}{/if}" placeholder="请输入科目名称" id="search3" class="form-control">
				</div>
			</div>
			<div class="row" style="margin-bottom:10px;">
				<div class="col-sm-4 form-group">
					<label for="search4">费用科目使用途径：</label>
					<select class="form-control" name="esuseway"id="search4">
						<option>请选择</option>
						{volist name="esuseway" id="row"}
						<option value="{$row.id}" {if isset($get.esuseway)&&$get.esuseway==$row.id}selected{/if}>{$row.title}</option>
						{/volist}
					</select>
				</div>
				<div class="col-sm-4 form-group">
					<label for="search5">所属二级科目：</label>
					<input type="text" name="pid" value="{if isset($get.pid)}{$get.pid}{/if}" placeholder="请输入科目名称"  class="form-control" id="search5">
				</div>
				<div class="col-sm-4 form-group">
					<label for="search6">费用科目对应渠道类型：</label>
					<select class="form-control" name="channeltypes" id="search6">
						<option>请选择</option>
						{volist name="channel_types1" id="row"}
						<option value="{$row.id}" {if isset($get.channeltypes)&&$get.channeltypes==$row.id}selected{/if}>{$row.title}</option>
						{/volist}
					</select>
				</div>
			</div>
			<div class="row">
				<div class="col-sm-12" style="text-align: center;">
					<button class="btn btn-info" type="submit">查询</button>
					<button class="btn btn-info" type="reset" id="reset">清空查询条件</button>
				</div>
			</div>

		</form>
		<script>
			$(function () {
				$('#reset').on('click',function () {
					$('#search1,#search2,#search3,#search4,#search5,#search6').val('')
					$('#form1').submit()
					return false
				})
			})
		</script>
	</div>
	<div class="padding-10">
		<table class="table table-striped table-bordered table-hover bud_hei text-center" id="editable">
			<thead>
			<tr class="info">
				<th class="text-center">三级科目编号</th>
				<th class="text-center">三级科目</th>
				<th class="text-center">对应财务费用科目</th>
				<th class="text-center">费用科目使用途径</th>
				<th class="text-center">费用科目对应渠道类型</th>
				<th class="text-center">所属二级科目</th>
				<th class="text-center">创建时间</th>
				<th class="text-center">修改时间</th>
				<th class="text-center">操作</th>
			</tr>
			</thead>
			<tbody>
			{volist name="data" id="row"}
			<tr class="gradeX">
				<td>{$row.sn}</td>
				<td>{$row.title}</td>
				<td>{$row.fifeiyongkemu}</td>
				<td>{$row.channeltypess}</td>
				<td>{$row.esuseways}</td>
				<td>{$row.pid_title}</td>
				<td>{$row.ctime}</td>
				<td>{$row.ptime}</td>
				<td class="center">
					<a href="javascript:;" data-id="{$row.id}"  class="xiugai">修改</a>&nbsp;&nbsp;<a href="javascript:;" data-id="{$row.id}" class="shanchu">删除</a>
				</td>
			</tr>
			{/volist}

			</tbody>

		</table>
		<div class="row text-center" id="pageText" style="padding: 0;margin: 0;">
			<div class="col-sm-6 text-left"><div class="padding-10 countSize">共{$count}条记录，{$maxpage}页&nbsp;&nbsp;</div></div>
			<div class="col-sm-6 text-right">{$page}</div>
		</div>


	</div>

</body>
</html>
<script>
    $(function () {
        $('#tree').on('click',function () {
            var id = $(this).data('id')
            //iframe层-父子操作
            layer.open({
                type: 2,
                title: '费用科目树',
                area: ['400px', '500px'],
                fixed: false, //不固定
                maxmin: true,
                content: '{:url("feiyongkemu1/jstree")}?id='+id
            });
            return false
        })
        //新增
        $('#new').on('click',function () {
            var esuseway = '<div class="row form-group">\n' +
                '<label class="col-sm-3 control-label">费用科目使用途径：</label>\n' +
                '<div class="col-sm-9">\n'
				{volist name="esuseway" id="row"}
				esuseway += '<label class="checkbox-inline">' +
				'<input type="checkbox" name="esuseway[]" value="{$row.id}" class="check" data-id="sub{$row.id}">{$row.title}</label>\n';
				{/volist}
                esuseway += '</div></div>'

                {volist name="esuseway" id="row"}
                    {if isset($row._child)}
                esuseway += '<div class="row form-group" id="sub{$row.id}" style="display:none;">\n' +
                    '<label class="col-sm-3 control-label">{$row.title}类型</label>\n' +
                    '<div class="col-sm-9">';

                    {volist name="row._child" id="row2" key="k"}
                    esuseway += '<label class="checkbox-inline">' +
                        '<input type="radio" name="tejiabuchatype" value="{$row2.id}" {if $k==1}checked{/if} >{$row2.title}</label>\n';
                    {/volist}
                esuseway += '</div></div>';
                        {/if}
                {/volist}

           var yiji = "<select name=\"pid\" id=\"pid\" class='form-control'>" +
                "<option value=\"\">请选择</option>" +
                "{volist name="yiji" id="row"}" +
            	"<option value=\"{$row.id}\">{$row.title}</option>" +
            	"{/volist}" +
            	"</select>";

            var fifeiyongkemu = "<select name=\"fifeiyongkemu\" id=\"fifeiyongkemu\" class='form-control'>" +
                "<option value=\"\">请选择</option>" +
                "{volist name="fifeiyongkemu" id="row"}" +
            	"<option value=\"{$row.id}\">{$row.title}</option>" +
            	"{/volist}" +
            	"</select>";

			var channeltypes = '<div class="row form-group">\n' +
				'<label class="col-sm-3 control-label">费用科目对应渠道类型：</label>\n' +
				'<div class="col-sm-9">\n'
			{volist name="channel_types1" id="row"}
                 channeltypes += '<label class="checkbox-inline">' +
				'<input type="checkbox" name="channeltypes[]" value="{$row.id}" >{$row.title}</label>\n';
			{/volist}
                channeltypes += '</div></div>'
            var freekmlx ='<div class="row form-group">\n'+
                    '<label class="col-sm-3 control-label">费用科目类型：<span class="colorRed">!!</span></label>\n'+
                    '<div class="col-sm-9">\n';
                        {volist name="feitype" id="row" key="k"}
                         freekmlx+='<label for="radio-inline">'+
                            '<input type="radio" name="freekmlx" value="{$row.id}" {if $k==1}checked {/if}> {$row.title}'+
                        '</label>\n'
                       {/volist}
                    freekmlx+='</div>\n</div>'
                var chenliechange ='<div class="row form-group">'+
                    '<label class="col-sm-3 control-label">陈列选择 : <span class="colorRed">!!</span> </label>'+
                    '<div class="col-sm-9">'+
                        '<label for="radio-inline">\n'+
                            '<input type="radio" name="chenlie" value="0" checked> 不适用'+
                        '</label>\n'+
                        '<label for="radio-inline">\n'+
                            '<input type="radio" name="chenlie" value="1"> 可选择陈列位置类型尺寸'+
                        '</label>\n'+
                    '</div>'+
                '</div>'
            var payway = '<div class="row form-group">'+
                    '<label class="col-sm-3 control-label">对应支付方式: <span class="colorRed">!!</span> </label>'+
                    '<div class="col-sm-9">';
                    {volist name="pay" id="vo"}
                       payway+= '<label for="checkbox-inline">'+
                            '<input type="checkbox" name="payway[]" value="{$vo.id}" class="check"> {$vo.title}\n'+
                        '</label>\n'
                        {/volist}
                       
                       payway+= '<span class="colorRed">（注：如未设定则默认支持所有支付方式）</span>'+
                    '</div>'+
                '</div>'
            $('body').append('<div class="channel_popbox" id="channel_popbox">' +
                '<div class="channel_pop_content ibox" style="width: 800px;margin-left:-400px;height:550px;margin-top:-275px;overflow: scroll"><div class="ibox-header"><button style="position: absolute;right: 7px;top: 3px;" type="button" class="close" data-dismiss="modal"><span aria-hidden="true" style="font-size:28px;">×</span><span class="sr-only">关闭</span>\n' +
                '</button><h2 style="text-align:center;" class="title_color">新增</h2></div>' +
                '<div class="ibox-content">' +
                '<form role="form" id="formadd" method="post" action="{:url("add")}">\n' +
                '<div class="row form-group">\n' +
                '<label class="col-sm-3 control-label">三级科目名称</label>\n' +
					'<div class="col-sm-9">'+
                '<input name="title" type="text" placeholder="三级科目名称" class="form-control">\n' +
                '</div>' +
                '</div>\n' +
                '<div class="row form-group">\n' +
                '<label class="col-sm-3 control-label">三级科目编号</label>\n' +
                '<div class="col-sm-9">'+
                '<input name="sn" type="text" placeholder="三级科目编号" class="form-control">\n' +
                '</div>' +
                '</div>\n' +
                '<div class="row form-group">\n' +
                '<label class="col-sm-3 control-label">所属二级科目</label>\n' +
                '<div class="col-sm-9">'+
                yiji +
                '</div>' +
                '</div>\n' +
                freekmlx+
                esuseway +
                '<div class="row form-group">\n' +
                '<label class="col-sm-3 control-label">对应财务费用科目</label>\n' +
                '<div class="col-sm-9">'+
                fifeiyongkemu +
                '</div>' +
                '</div>\n' +
                 channeltypes+
                 chenliechange+
                 payway+
                '<div class="row form-group">\n' +
                '<label class="col-sm-3 control-label">描述</label>\n' +
                '<div class="col-sm-9">'+
                '<textarea name="brief" class="form-control" id="brief"></textarea>\n' +
                '</div>\n' +
                '</div>\n' +
                '<div class="text-center" style="padding:20px 0">\n' +
                '<input class="btn btn-sm btn-primary" type="submit" id="tijiao" value="提 交">\n' +
                '</div>\n' +
                '</form>' +
                '</div>' +
                '</div>' +
                '</div>')

        })
        $('body').on('click','#channel_popbox .close',function () {
            $('#channel_popbox').remove()
        })

        $('body').on('click','#channel_popbox #tijiao',function () {
            var form =  $('#channel_popbox #formadd')
            var data = form.serialize()
            $.ajax({
                'type':'post',
                'url':form.attr('action'),
                'data':data,
                'dataType':'json',
                'success':function (data) {
                    if(data.success){
                        swal({
                            title: data.msg,
                            type: "success"
                        },function(){
                            location.reload()
						});

                    }else
                        swal({
                            title: data.msg,
                            type: "warning"
                        });
                }
            })
			return false
        })

		//修改
		$('.xiugai').on('click',function () {

            var id = $(this).data('id')
            //iframe层-父子操作
            layer.open({
                type: 2,
                title: '修改',
                area: ['800px', '570px'],
                fixed: false, //不固定
                maxmin: true,
                content: '{:url("updateview")}?id='+id
            });
            return false

        })

		//删除
        $('.shanchu').click(function () {
            var id = $(this).data('id')
            swal({
                title: "您确定要删除这条信息吗",
                text: "删除后将无法恢复，请谨慎操作！",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "删除",
                closeOnConfirm: false
            }, function () {
                $.ajax({
                    'type':'post',
                    'url':'{:url("delete")}',
                    'data':{'id':id},
                    'dataType':'json',
                    'success':function (data) {
                        if(data.success){
                            location.reload()
                        }else
                            swal(data.msg, "", "error");
                    }
                })

            });
        });

    })
</script>